//
//  ViewController.m
//  IOS4
//
//  Created by blue on 15-11-23.
//  Copyright (c) 2015年 ZX. All rights reserved.
//

#import "ViewController.h"
#import "inTableViewController.h"

@interface ViewController () <ZXInPutDelegate>
{
    NSArray * z;
    NSArray * x;
    NSIndexPath * XIndexPath;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    z=@[
        @"张鑫",
        @"肖遥",
        @"尹彬"
        ];
    x=@[
        @"15089651258",
        @"18279458691",
        @"13598469654"
        ];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return z.count;
}
- (UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * con = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    con.textLabel.text =z[indexPath.row];
    con.detailTextLabel.text=x[indexPath.row];
    //记录行数
    XIndexPath = indexPath;
    con.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return con;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    inTableViewController * con = [[inTableViewController alloc]initWithStyle:UITableViewStyleGrouped];
    UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
    con.tel = cell.detailTextLabel.text;
    con.delegate = self;
    [self.navigationController pushViewController:con animated:YES];
    
}

- (void)inputFinshed:(NSString *)text
{
    //变成可数组
    NSMutableArray * arr = x.mutableCopy;
    
    [arr replaceObjectAtIndex:XIndexPath.row withObject:text];
    x = arr;
    [self.tableView reloadData];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
